#!/bin/sh

scpdir=$1
shift
ipfile="ip.txt"
# edit user
user=root
aimdir=$1

cat $ipfile | while read ip; do
    suffix=$(echo $ip | cut -d '.' -f3-4)
    scp -r $user@$ip:$aimdir$suffix $scpdir/
done